<template>
  <el-button
    v-bind="$attrs"
    :disabled="buttonShow||disabled"
    @click="handleClick"
  >
    <slot />
  </el-button>
</template>
<script>
import store from '@/store'

export default {
  name: 'BeeButton',
  props: {
    code: {
      type: String,
      default: ''
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      buttonShow: false
    }
  },
  created() {
    this.checkShow()
  },
  methods: {
    handleClick(evt) {
      this.$emit('click', evt)
    },
    checkShow() {
      const buttonMenus = store.getters.menus
      if (buttonMenus[this.code] !== undefined) {
        this.buttonShow = !buttonMenus[this.code]
      } else {
        this.buttonShow = true
      }
    }
  }
}
</script>
